//
//  APPGuidView.m
//  GiftItems
//
//  Created by lanou3g on 15/10/7.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "APPGuidView.h"

@implementation APPGuidView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentSize = CGSizeMake(kWidth * 3, 0);
        self.pagingEnabled = YES;
        self.showsHorizontalScrollIndicator = NO;
        self.bounces = NO;
        [self addSubview];
    }
    return self;
}

- (void)addSubview {
    NSArray *images = @[@"001.png",@"002.png",@"003.png"];
    for (int i = 0; i < images.count; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth * i, 0, kWidth, kHeight)];
        imageView.userInteractionEnabled = YES;
        imageView.image = [UIImage imageNamed:images[i]];
        if (i == 2) {
            [self addButtonForImageView:imageView];
        }
        [self addSubview:imageView];
    }
}


- (void)addButtonForImageView:(UIImageView *)imageView {
    
        self.button = [UIButton buttonWithType:UIButtonTypeCustom];
        self.button.frame = CGRectMake((kWidth - 100) / 2, kHeight - 100, 100, 30);
        [self.button setTitle:@"立即体验" forState:UIControlStateNormal];
        self.button.layer.cornerRadius = 5;
        self.button.backgroundColor = kRGB(250.0, 200.0, 255.0);
        [imageView addSubview:self.button];
}

@end
